package com.bh.weapp.controller.common;

import com.bh.common.annotation.RepeatSubmit;
import com.bh.common.core.controller.BaseController;
import com.bh.common.core.domain.AjaxResult;
import com.bh.common.utils.StringUtils;
import com.bh.kysys.domain.JcZone;
import com.bh.kysys.service.IJcZoneService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 行政区域Controller
 *
 * @author slx
 * @date 2023-03-24
 */
@Api(tags = {"COMMON外部用户用户信息接口"})
@RestController
@RequestMapping("/api/common/kysys/zone")
public class JcZoneApiController extends BaseController {

    @Autowired
    private IJcZoneService jcZoneService;

    /**
     * 查询行政区域树列表
     */
    @RepeatSubmit
    @ApiOperation("查询行政区域树列表")
    @GetMapping("/childList")
    public AjaxResult childList(Long zid) {
        if (StringUtils.isEmpty(zid)) {
            zid = 0L;
        }
        List<JcZone> list = jcZoneService.selectJcZoneListByZid(zid);
        return success(list);
    }

    /**
     * 查询行政区域
     */
    @ApiOperation("查询行政区域")
    @GetMapping("/getInfo/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        JcZone jcZone = jcZoneService.selectJcZoneById(id);
        return AjaxResult.success(jcZone);
    }
}
